/**
  * Author: Mei
  * Date: 2020-12-30 19:13
  * Description: 通过模板类的特化和递归结合来展开tuple
  *
  *
  */
#include "../head.h"

template<class Tuple, size_t N>
struct TuplePrinter {
    static void print(const Tuple &t) {
        TuplePrinter<Tuple, N - 1>::print(t);
        cout << ", " << get<N - 1>(t);
    }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
    static void print(const Tuple &t) {
        cout << get<0>(t);
    }
};

template<class ... Args>
void PrintTuple(const tuple<Args...> &t) {
    cout << "(";
    TuplePrinter<decltype(t), sizeof...(Args)>::print(t);
    cout << ")\n";
}

int main() {
    tuple<int, short, double, char, bitset<8>> tp = make_tuple(1, 2, 3, 'a', 10);
    cout << get<4>(tp) << endl;
    PrintTuple(tp);

    return 0;
}